angular.module('app.directives')

.directive('configure', ['dragularService', function(dragularService) {
    return {
        restrict: 'EA',
        templateUrl: 'directive/configure/configure.html',
        scope: {
            data: '=',
            configItems: '='
        },
        link: function($scope, element, attributes) {
            $scope.attrs = Object.keys($scope.data[0]).map(function(attr) {
                return { colName: attr };
            });
            dragularService('.dragularSrc', {
                containersModel: $scope.attrs,
                scope: $scope,
                copy: true,
                accepts: function(z){
                    return false;
                }
            });
            dragularService('.dragularTarget', {
                removeOnSpill: true,
                scope: $scope
            });
            // $scope.$watch(attributes.data, function(newValue, oldValue, scope) {
            //     $scope.data = newValue;
            //     $scope.attrs = Object.keys($scope.data[0]).map(function(attr) {
            //         return { colName: attr };
            //     });
                
            // }, true);
            // $scope.$watch(attributes.configItems, function(newValue, oldValue, scope) {
            //     $scope.configItems = newValue;
                
            // }, true);
        }
    }
}])
